<?php
/*
  $Id: index.php $
  Mefobe Cart Solutions
  http://www.mefobemarket.com

  Copyright (c) 2009 Wuxi Elootec Technology Co., Ltd;  Copyright (c) 2006 osCommerce

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $osC_Language->getTextDirection(); ?>" xml:lang="<?php echo $osC_Language->getCode(); ?>" lang="<?php echo $osC_Language->getCode(); ?>">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $osC_Language->getCharacterSet(); ?>" />
<meta http-equiv="x-ua-compatible" content="ie=7" />

<title><?php echo ($osC_Template->hasMetaPageTitle() ? $osC_Template->getMetaPageTitle() . ' - ' : '') . STORE_NAME; ?></title>
<base href="<?php echo osc_href_link(null, null, 'AUTO', false); ?>" />

<link rel="stylesheet" type="text/css" href="templates/<?php echo $osC_Template->getCode(); ?>/stylesheet.css" />
<link rel="stylesheet" type="text/css" href="ext/autocompleter/Autocompleter.css" />

<!--[if IE]>
<style type="text/css">
  #productInfoTab a {
    top:11px;
  }
  
  #productInfoTab a.unselect {
    top:13px;
  }
</style>
<![endif]-->
<?php
  if ($osC_Template->hasPageTags()) {
    echo $osC_Template->getPageTags();
  }

  if ($osC_Template->hasJavascript()) {
    $osC_Template->getJavascript();
  }
  
  if ($osC_Template->hasStyleSheet()) {
    $osC_Template->getStyleSheet();
  }
?>

<meta name="Generator" content="TomatoCart" />
</head>
<body>
<?php
  if ($osC_Template->hasPageHeader()) {
?>

<div id="pageHeader">
  <div id="headerBar">
    <div id="navLanguages">    
          <?php
            foreach ($osC_Language->getAll() as $value) {
              echo osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('language', 'currency')) . '&language=' . $value['code'], 'AUTO'), $osC_Language->showImage($value['code']));
            }
          ?>
        </div>
    <?php
      echo osc_link_object(osc_href_link(FILENAME_DEFAULT), osc_image($osC_Template->getLogo(), STORE_NAME), 'id="siteLogo"');
    ?>
  </div>
  <div id="navigation">
    <div id="navigationInner">
      <?php
    global $osC_Database,$osC_Language;

      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('home')) . '&nbsp;&nbsp;';
      
//      $Qarticles = $osC_Database->query('select ad.articles_id, ad.articles_name from :table_articles a, :table_articles_description ad where a.articles_id = ad.articles_id and ad.language_id = :language_id and a.articles_status = 1 and a.articles_categories_id = 1 order by a.articles_order');
//      $Qarticles->bindTable(':table_articles', TABLE_ARTICLES);
//      $Qarticles->bindTable(':table_articles_description', TABLE_ARTICLES_DESCRIPTION);
//      $Qarticles->bindInt(':language_id', $osC_Language->getID());
//      $Qarticles->setCache('box-information-' . $osC_Language->getCode(), 100);
//      $Qarticles->execute();      
//      
//      while ($Qarticles->next()) {
//         echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'articles&articles_id='.$Qarticles->value('articles_id')), $Qarticles->value('articles_name')) . '&nbsp;&nbsp;';
//      }
//      
//      $Qarticles->freeResult(); 

      $Qac = $osC_Database->query('select cd.articles_categories_id, cd.articles_categories_name from :table_articles_categories c, :table_articles_categories_description cd where c.articles_categories_id = cd.articles_categories_id and cd.language_id = :language_id and c.articles_categories_status = 1 order by c.articles_categories_order, cd.articles_categories_name limit :max_display_articles_categories');
      $Qac->bindTable(':table_articles_categories', TABLE_ARTICLES_CATEGORIES);
      $Qac->bindTable(':table_articles_categories_description', TABLE_ARTICLES_CATEGORIES_DESCRIPTION);
      $Qac->bindInt(':language_id', $osC_Language->getID());
      $Qac->bindInt(':max_display_articles_categories', BOX_ARTICLES_CATEGORIES_MAX_LIST);
      $Qac->setCache('box_articles_categories-' . $osC_Language->getCode(), BOX_ARTICLES_CATEGORIES_MAX_LIST);
      $Qac->execute();

      while ($Qac->next()) {
        if($Qac->valueInt('articles_categories_id') > 1){          
          echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'articles_categories&articles_categories_id='.$Qac->value('articles_categories_id')), $Qac->value('articles_categories_name')) . '&nbsp;&nbsp;';
        }
      }

      $Qac->freeResult();
        
      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'contact'), $osC_Language->get('box_information_contact')) . '&nbsp;&nbsp;';
      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'sitemap'), $osC_Language->get('box_information_sitemap')) . '&nbsp;&nbsp;';
           
    ?>  
    
    <div style="float: right;width: 206px; margin-bottom: -17px;">
        <form name="search" action="<?php echo osc_href_link(FILENAME_SEARCH, null, 'NONSSL', false);?>" method="get">
          <p class="keywords"><?php echo osc_draw_input_field('keywords', null, 'maxlength="20"') ?></p>
          <p><input type="image" src="<?php echo 'templates/' . $osC_Template->getCode() . '/images/button_quick_find.png'; ?>" alt="<?php echo $osC_Language->get('box_search_heading'); ?>" title="<?php echo $osC_Language->get('box_search_heading'); ?>" id="quickSearch" /><?php echo osc_draw_hidden_session_id_field(); ?></p>
        </form>
      </div>            
    </div>    
  </div>
  
</div>

<?php
}
?>

<div id="slideShow">
  <?php 
    $slideshow = $osC_Template->getContentGroup('slideshow');
    if ($slideshow !== false) {
      echo $slideshow;
    }
  ?>
</div>
<?php
      if ($osC_Services->isStarted('breadcrumb')) {
  ?>
      <div id="breadcrumbPath">
      <?php
        echo $breadcrumb->trail(' &raquo; ');
      ?>        
      </div>
  <?php
    }
  ?>
<div id="pageWrapper">
  <div id="pageBlockLeft">
  <?php
    $content_left = $osC_Template->getBoxGroup('left');

    if (!empty($content_left)) {
  ?>

    <div id="pageColumnLeft">
      <div class="boxGroup">
      <?php
          echo $content_left;
      ?>
      </div>
    </div>

  <?php
    } else {
  ?>
    <style type="text/css"><!--
      #pageContent {
        width: 745px;
      }
    //--></style>
  <?php
    }
  ?>
  
    <div id="pageContent">

      <?php
        if ($messageStack->size('header') > 0) {
          echo $messageStack->output('header');
        }

        if ($osC_Template->hasPageContentModules()) {
          foreach ($osC_Services->getCallBeforePageContent() as $service) {
            $$service[0]->$service[1]();
          }

          $content_before = $osC_Template->getContentGroup('before');
          if (!empty($content_before)) {
            echo $content_before;
          }
        }

        if ($osC_Template->getCode() == DEFAULT_TEMPLATE) {
          include('templates/' . $osC_Template->getCode() . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename());
        } else {
          if (file_exists('templates/' . $osC_Template->getCode() . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename())) {
            include('templates/' . $osC_Template->getCode() . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename());
          } else {
            include('templates/' . DEFAULT_TEMPLATE . '/content/' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename());
          }
        }
      ?>

      <div style="clear: both;"></div>

      <?php
        if ($osC_Template->hasPageContentModules()) {
          foreach ($osC_Services->getCallAfterPageContent() as $service) {
            $$service[0]->$service[1]();
          }
        
          $content_after = $osC_Template->getContentGroup('after');
          if (!empty($content_after)) {
            echo $content_after;
          }
        }
      ?>

    </div>
  </div>

<?php
    $content_right = $osC_Template->getBoxGroup('right');
  ?>
  <?php
    if (!empty($content_right)) {
  ?>
      <div id="pageColumnRight">
        <div class="boxGroup">
      <?php
          echo $content_right;
      ?>
        </div>
      </div>

  <?php
    } elseif ( empty($content_right) && empty($content_left) ) {
  ?>
      <style type="text/css"><!--
      #pageContent, #pageBlockLeft{
        width:960px;
      }
      --></style>
  <?php
    } elseif ( empty($content_right) ) {
  ?>
      <style type="text/css"><!--
      #pageContent {
        width: 745px;
      }

      #pageBlockLeft{
        width:960px;
      }
      //--></style>
  <?php
    }

    unset($content_left);
    unset($content_right);
  ?>
</div>

<?php 
  if ($osC_Template->hasPageFooter()) {
?>

  <div id="pageFooter">
    <?php
    global $osC_Database,$osC_Language;

      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('home')) . '&nbsp;&nbsp;';
      
      $Qarticles = $osC_Database->query('select ad.articles_id, ad.articles_name from :table_articles a, :table_articles_description ad where a.articles_id = ad.articles_id and ad.language_id = :language_id and a.articles_status = 1 and a.articles_categories_id = 1 order by a.articles_order');
      $Qarticles->bindTable(':table_articles', TABLE_ARTICLES);
      $Qarticles->bindTable(':table_articles_description', TABLE_ARTICLES_DESCRIPTION);
      $Qarticles->bindInt(':language_id', $osC_Language->getID());
      $Qarticles->setCache('box-information-' . $osC_Language->getCode(), 100);
      $Qarticles->execute();      
      
      while ($Qarticles->next()) {
         echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'articles&articles_id='.$Qarticles->value('articles_id')), $Qarticles->value('articles_name')) . '&nbsp;&nbsp;';
      }
      
      $Qarticles->freeResult(); 
        
      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'contact'), $osC_Language->get('box_information_contact')) . '&nbsp;&nbsp;';
      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'guestbook&new'), $osC_Language->get('guest_book')) . '&nbsp;&nbsp;';
      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_INFO, 'sitemap'), $osC_Language->get('box_information_sitemap')) . '&nbsp;&nbsp;';
      echo '&nbsp;&nbsp;' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'rss'), osc_image(DIR_WS_IMAGES . 'rss16x16.png') . '<span>RSS</span>') . '&nbsp;&nbsp;';
           
    ?>  
    <div style="clear:both"></div>
    <p style="margin: 3px;">
      <?php
        echo sprintf($osC_Language->get('footer'), date('Y'), osc_href_link(FILENAME_DEFAULT), STORE_NAME);
      ?>
    </p>
  </div>
  
<?php 
    if ($osC_Services->isStarted('banner') && $osC_Banner->exists('468x60')) {
      echo '<p align="center">' . $osC_Banner->display() . '</p>';
    }
  }
?>

<script type="text/javascript" src="ext/autocompleter/Autocompleter.js"></script>
<script type="text/javascript" src="ext/autocompleter/Autocompleter.Request.js"></script>
<script type="text/javascript" src="ext/autocompleter/Observer.js"></script>
<script type="text/javascript" src="includes/javascript/auto_completer.js"></script>
<!--<script type="text/javascript" src="includes/javascript/popup_cart.js"></script>-->
<!--<script type="text/javascript" src="includes/javascript/bookmark.js"></script>-->

<script type="text/javascript">
  window.addEvent('domready', function() {
    
    new TocAutoCompleter('keywords', {
      sessionName: '<?php echo $osC_Session->getName(); ?>',
      sessionId: '<?php echo $osC_Session->getID(); ?>',
      template: '<?php echo $osC_Template->getCode(); ?>',
      width: 300
    });
  });
</script>


<?php
  if ($osC_Services->isStarted('piwik')) {
    echo $toC_Piwik->renderJs();
  }
?>
</body>
</html>